<template>
	<view class="page">
		
		<view class="order-info">
			<view class="info-list">
				<view class="list">
					<view class="title">订单编号:</view>
					<view class="content">
						<text>{{orderData.order_sn}}</text>
						<text class="btn">复制</text>
					</view>
				</view>
				<view class="list">
					<view class="title">下单时间:</view>
					<view class="content">
						<text>{{orderData.create_time}}</text>
					</view>
				</view>
				<view class="list">
					<view class="title">订单更新时间:</view>
					<view class="content">
						<text>{{orderData.update_time}}</text>
					</view>
				</view>
				
				<view class="list">
					<view class="title">备注信息:</view>
					<view class="content">
						<text>{{orderData.goods_details_txt}}</text>
						<!-- <text>{{orderData.goods_video_url}}</text> -->
						<!-- <u--textarea v-model="orderData.goods_details_txt" readOnly height="80" maxlength="150" count="true"
							border="bottom"></u--textarea> -->
					</view>
				</view>
				<view class="list" v-if="orderData.goods_store_result_txt">
					<view class="title">鉴定反馈:</view>
					<view class="content">
						<text>{{orderData.goods_store_result_txt}}</text>
						<!-- <text>{{orderData.goods_video_url}}</text> -->
						<!-- <u--textarea v-model="orderData.goods_details_txt" readOnly height="80" maxlength="150" count="true"
							border="bottom"></u--textarea> -->
					</view>
				</view>
				<view class="">
					<view class="title">视频:</view>
					<view class="content">
						<video :src="orderData.goods_video_url" controls autoplay loop muted 
							style="width: 100%;height: 200px; margin: auto;"></video>
					</view>
				</view>
				<view class="">
					<view class="title">图片:</view>
					<view class="content">
						<view class="thumb" v-for="el in orderData.img_list">
							<image :src="el" mode=""></image>
						</view>
					</view>
				</view>
				
			</view>
		</view>

		
		<!-- 订单明细 -->
		<view class="order-details">
			<view class="details-list">
				<view class="list action">
					<view class="title">
						<text>实付款：</text>
					</view>
					<view class="price">
						<text>￥{{orderData.appraiser_fee}}</text>
					</view>
				</view>
			</view>
		</view>
		<!-- 底部按钮 -->
		<view class="footer-btn">

			<view class="btn" v-if="orderData.status == 1 && isStore" >
				<text class="action" @click="confimOrderExpress">鉴定</text>
			</view>
			<view class="btn" v-if="orderData.status == 2">
				<text class="action" @click="delOrder">删除订单</text>
			</view>
		
		</view>
	</view>
</template>

<script>
	import {
		orderAppariser,
		delOrderAppariser
	} from '@/config/api.js';
	export default {
		data() {
			const orderInfo = uni.getStorageSync('order_info');
			return {
				orderData: orderInfo,
				queryList: {
					id: ''
				},
				isStore: false,
				express_name: '',
				express_order: '',
				goodsData: {},
				addressData: {},
				retreatInfo: {},
			};
		},

		onLoad(options) {
			if(options.store_id)this.isStore = options.store_id;
			// this.queryList.id = options.oderId;
			// console.log(options)
			// getOrderInfoById(this.queryList).then(res => {
			// 	this.orderData = res.orderData;
			// 	this.goodsData = res.goodsData;
			// 	this.addressData = res.addressData;
			// 	this.retreatInfo = res.retreatInfo;
			// })
		},

		methods: {
			errorfn(e){
				console.log(e)
			},
			
			delOrder() {
				const _this = this;
				uni.showModal({
					title: '提示',
					content: '确定要删除该订单？',
					success: function(res) {
						if (res.confirm) {
							delOrderAppariser({
								id: _this.orderData.id,
								store_id: _this.isStore||''
							}).then(res => {
								uni.showToast({
									title: '成功',
									icon: 'success',
								});
							})


						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			confimOrderExpress() {
				const _this = this;
				uni.showModal({
					title: '提示',
					editable: true,
					placeholderText: '请输入鉴定反馈',
					success: function (res) {
						if (res.confirm) {
							orderAppariser({
								id: _this.orderData.id,
								goods_store_result_txt: res.content,
								status: 2,
							}).then(res => {
								uni.showToast({
									title: '成功',
									icon: 'success',
								});
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			/**
			 * 售后点击
			 */
			onApplyAftersales() {
				uni.navigateTo({
					url: '/pages/AfterSaleType/AfterSaleType',
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	@import 'OrderDetails.scss';
</style>